package org.simpleframework.mvc.type;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 存储处理完后的结果数据,以及显示该数据的视图
 * @author icanci
 * @date Created in 2021/03/06 21:35
 * @version 1.0
 */
public class ModelAndView {
    /**
     * 页面所在的路径
     */
    @Getter
    private String              view;
    /**
     * 页面的data数据
     */
    @Getter
    private Map<String, Object> model = new HashMap<>();

    public ModelAndView setView(String view) {
        this.view = view;
        return this;
    }

    /**
     * modelAndView.setView("hello.jsp").addViewData("aaa", "bbb");
     * @param attributeName 参数
     * @param attributeValue 值
     * @return 返回视图
     */
    public ModelAndView addViewData(String attributeName, Object attributeValue) {
        model.put(attributeName, attributeValue);
        return this;
    }
}
